package org.japo.java.swing.igu;

import java.awt.Color;
import java.awt.HeadlessException;
import java.awt.Point;
import java.util.Random;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import org.japo.java.swing.listeners.GER;

public class IGU extends JFrame {

    Random azar = new Random(System.currentTimeMillis());
int xBotnA = azar.nextInt(1100 - 100 +1 ) + 100;
        int yBotonA = azar.nextInt(650 - 50 + 1) + 50;
    private JButton btnAceptar;

    public IGU() throws HeadlessException {
        iniciarComponentes();

    }

    private void iniciarComponentes() {

        
        
        //Gestor de eventos de raton
        GER ger = new GER(this);

        JPanel pnlPrincipal = new JPanel(null);
        pnlPrincipal.setBackground(Color.BLUE);
        pnlPrincipal.addMouseMotionListener(ger);
        pnlPrincipal.addMouseListener(ger);
        pnlPrincipal.setOpaque(true);

        //Boton Aceptar
        btnAceptar = new JButton();
        btnAceptar.setText("Cógeme");
        btnAceptar.setSize(100, 30);
        btnAceptar.setLocation(xBotnA, yBotonA);
        pnlPrincipal.add(btnAceptar);

        // Ventana principal
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setTitle("Mouse Acecha");
        setContentPane(pnlPrincipal);
        setResizable(false);
        setSize(1200, 700);
        setLocationRelativeTo(null);
    }

    public void MouseAcecha(int x, int y, int yAleatoria, int xAleatoria) {
        btnAceptar.setLocation(x + 10,y + 10);
//         btnAceptar.setLocation(xBotnA, yBotonA);

    }

    public void recolocarBoton() {
        btnAceptar.setLocation(550, 300);
    }

}
